package me.zk;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Predicate;

/**
 * @Author: zhang kai
 * @Date: 2022/07/12
 * @Description:
 */
public class Demo2 {
    public static void main(String[] args) {
        //方法引用
        Consumer<Integer> c = System.out::println;
        forEach(Arrays.asList(1,2,3), c);
    }
    public static <T> void forEach(List<T> list, Consumer<T> c) {
       for (T i : list) {
           c.accept(i);
       }
    }

}
